package com.vue.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.vue.mapper.CateGoryMapper;
import com.vue.pojo.CateGory;
import com.vue.service.CateGoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class ImCateGoryService extends ServiceImpl<CateGoryMapper,CateGory> implements CateGoryService {
    @Autowired CateGoryMapper cateGoryMapper;
    @Override
    public Page<CateGory> findll(Integer pagenumber, Integer pagesize) {
        Page<CateGory> page=new Page<>(pagenumber,pagesize);
        return cateGoryMapper.selectPage(page,null);
    }

    @Override
    public int delOne(Integer id) {
        return cateGoryMapper.deleteById(id);
    }

    @Override
    public int adllOne(CateGory cateGory) {
        return cateGoryMapper.insert(cateGory);
    }

    @Override
    public CateGory findOne(Integer id) {
        return cateGoryMapper.selectById(id);
    }

    @Override
    public CateGory fineByName(String name) {
        return cateGoryMapper.selectOne(new QueryWrapper<CateGory>().eq("name",name));
    }


}
